// Copyright © SixtyFPS GmbH <info@slint-ui.com>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial

import { StyleMetrics } from "std-widgets.slint";

global Glop := {
    property <int> hello: 42;
    property <int> second: 88;
    property <int> third: 102;
}

global DualBindingGlop := {
    property third <=> Glop.third;
}

Widget := Rectangle {
    property second <=> Glop.second;
}

TestCase := Rectangle {
    // This is meant to test an alias to a native global.
    // Unfortunately, this is only a native global with the Qt backend and not with the Test backend
    property <length> alias_to_native <=> StyleMetrics.text_cursor_width;
    property <int> alias_to_global <=> Glop.hello;
    property <bool> test: alias_to_native == StyleMetrics.text_cursor_width && alias_to_global == 42 && indirect == 88;
    property <int> indirect <=> widget.second;
    property <int> direct: Glop.second;
    property <int> dual <=> DualBindingGlop.third;

    widget := Widget { }
}

/*
```rust
let instance = TestCase::new().unwrap();
assert!(instance.get_test());
assert_eq!(instance.get_alias_to_global(), 42);
instance.set_alias_to_global(123);
assert_eq!(instance.get_alias_to_global(), 123);
assert_eq!(instance.get_indirect(), 88);
instance.set_indirect(99);
assert_eq!(instance.get_direct(), 99);
assert_eq!(instance.get_dual(), 102);

```

```cpp
auto handle = TestCase::create();
const TestCase &instance = *handle;
assert(instance.get_test());
assert_eq(instance.get_dual(), 102);
```

```js
let instance = new slint.TestCase({});
assert(instance.test);
assert.equal(instance.alias_to_global, 42);
instance.alias_to_global = 123;
assert.equal(instance.alias_to_global, 123);
assert.equal(instance.indirect, 88);
instance.indirect = 99;
assert.equal(instance.direct, 99);
assert.equal(instance.dual, 102);
```

*/
